home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Utilities / System / FKey / FKeys / dcl-ANSI (all) / dcl-ANSI README < prev    next >
Text File  |  1993-04-21  |  5KB  |  105 lines

  1. #if 0
  2.  
  3.  
  4. C's method of declaring variables and functions is one of the most confusing
  5. parts of the language.  Even old pros will double- and triple-check their
  6. arrays of pointers.  And the pathological cases are truly bizarre:
  7. "int(Int(int(Int)))" declares a function that accepts and returns an int, but
  8. "int(Int(int(int)))" declares a function that accepts another function,
  9. and _that_ function accepts and returns an int.  Weird stuff.
  10.  
  11. "dcl-ANSI" lets you type in a declaration, hit a few keys, and see what it
  12. means, in plain English.  Tell it "int *x[]()" and it tells you x is "type
  13. array[] of function with undefined parameters returning type pointer to int."
  14. It's based on the "dcl" program in section 5.12 of K&R, but, as the name
  15. implies, it fully understands ANSI.  (Well, OK, there are a few limitations.
  16. See below.)  And it's public domain.
  17.  
  18. There are two editions of this utility.  It was first created as a BBEdit
  19. extension, because (1) I like BBEdit and (2) BBEdit provides a particularly
  20. nice environment for hacks like this to live in.  If you keep BBEdit open
  21. while programming, you may prefer this version.  Otherwise, you'll probably
  22. want to use the second edition, the FKEY, because it's simpler:  just
  23. select your declaration, hit cmd-C and cmd-shift-9 [*], and the English
  24. explanation is in the clipboard, waiting for you to paste it somewhere.
  25.  
  26. That's so much simpler, in fact, that you may be wondering why I kept the
  27. BBEdit extension hanging around at all.  Well, because:  (1) I like BBEdit.
  28. (2) If you want to translate the FKEY into another language, or add your
  29. own specifiers for common typedefs, you'll have to recompile the code.
  30. But the extension's strings are in resources.  (You'll probably want to
  31. use Resorceror, which provides a handy little mechanism for editing arrays
  32. of C strings.)  (3) Tradition.  (4) You get an interface with the BBEdit
  33. extension:  you can input text that's been selected but not copied, and
  34. you can send the output to the clipboard, a window, or into a dialog box.
  35. (5) If you use BBXKeys and PwrSwitcher, and you leave BBEdit running all
  36. the time, you can get results with only a few more keystrokes than the
  37. FKEY.  (6) You have to use ResEdit to install the FKEY, yuck.
  38. (7) I like BBEdit.
  39.  
  40. Roughly in order of importance, the limitations are:
  41. • only one declaration at a time can be parsed;
  42. • the declarations may not be initialized;
  43. • the errors returned are sometimes not quite what you'd expect, so don't
  44.   take them as gospel or anything;
  45. • a semicolon terminates input, so a declaration is allowed to end with
  46.   one, but any other non-whitespace terminator produces an error;
  47. • specifiers are not parsed, so "short long" and "float int" and arrays of
  48.   void and other nonsense like that is considered valid;
  49. • only C specifiers are recognized, not ones you may have typedef'd, with
  50.   the exception of a few common ones--you can add your own by modifying
  51.   the BBEdit extension's resources or the FKEY's code;
  52. • the ellipsis token ("...") is not recognized;
  53. • comments are not recognized;
  54. • no C preprocessing is done, so line splicing, trigraphs, backslash
  55.   escape sequences, and #-stuff are not recognized;
  56. • the output can't be longer than 1K;
  57. • functions cannot be nested as parameters of functions more than six deep;
  58. • tokens longer than 100 characters might cause strangeness or a crash;
  59. • more than about a hundred nested pairs of parentheses may cause heap
  60.   corruption or a crash (2000 guarantees it).
  61.  
  62. As I said, dcl-ANSI is public domain;  it's free, and I've forsaken all
  63. rights and responsibilities to and for it.  I did this for the fun of it.
  64. Part of the fun is hearing from people--if you have any comments or
  65. suggestions, I'd like to hear from you!  And if you translate this or
  66. otherwise modify it, I'd especially like to hear about what you've done.
  67. Thank you.
  68.  
  69. Happy coding!
  70.  
  71. Jamie R. McCarthy
  72. Internet (at least for now):  k044477@kzoo.edu
  73. AppleLink (indefinitely):  j.mccarthy
  74. AppleLink, via Internet:  j.mccarthy@applelink.apple.com
  75.  
  76.  
  77. [*] This distribution gives the FKEY an ID of 9, so you invoke it with
  78. cmd-shift-9.  If you want to change that for some reason, just change
  79. the ID number to something else when you install it.
  80.  
  81. Instructions for installing an FKEY:  first, make a backup copy of your
  82. system file, just in case.  Double-click the provided FKEY file.  ResEdit
  83. should start up;  if not, get a copy of ResEdit 2.1.1 (or later).  Copy
  84. the selected 'FKEY' resource.  Close the file.  Open your system file, and
  85. ignore the warning (if any).  Paste.  Save.  Close your system file.  Quit
  86. ResEdit and restart.  If your system file is now hosed, well, that's what
  87. your backup copy is for.
  88.  
  89.  
  90. #endif
  91.  
  92.  
  93.  
  94. int(Int1(int(Int)));
  95. int Int1(int Int )
  96. {
  97.     Int = 5;
  98. }
  99.  
  100. int(Int2(int                     (int                )));
  101. int Int2(int unnamedFunctionParam(int unnamedIntParam))
  102. {
  103.     int aLocalVariable = unnamedFunctionParam(5);
  104. }
  105.